package com.cnsuning.jobtool.jobtools.line;

import org.apache.commons.io.FileUtils;
import org.junit.Test;

import java.io.File;
import java.io.IOException;

public class GetLine {
    @Test
    public void test() throws IOException {
        File file = new File("C:\\Users\\徐兴兴\\Desktop\\commit(1)\\commit");
        File targetFile = new File("src\\main\\java\\com\\cnsuning\\jobtool\\jobtools\\line\\result.txt");
        if (targetFile.exists()) targetFile.delete();
        File[] files = file.listFiles();
        for (File file1 : files)
        {
            String fileName = file1.getName();
            int line = FileUtils.readLines(file1).size();
            FileUtils.writeStringToFile(targetFile,fileName+"|"+line+"\n",true);
        }
    }
}
